cmake_minimum_required(VERSION 3.5)
project(Calculator)

set(CMAKE_CXX_STANDARD 11)

option(USE_PLUS "Enable addition" ON)
option(USE_MINUS "Enable subtraction" ON)
option(USE_MUL "Enable multiplication" ON)
option(USE_DIV "Enable division" ON)

if (USE_PLUS)
    add_definitions(-DUSE_PLUS)
endif()

if (USE_MINUS)
    add_definitions(-DUSE_MINUS)
endif()

if (USE_MUL)
    add_definitions(-DUSE_MUL)
endif()

if (USE_DIV)
    add_definitions(-DUSE_DIV)
endif()

add_library(calculator SHARED calculator.cpp)

# Set compiler flags for different platforms
if (PLAT STREQUAL "LINUX")
    set_target_properties(calculator PROPERTIES COMPILE_FLAGS "-DLINUX")
elseif (PLAT STREQUAL "WIN")
    set_target_properties(calculator PROPERTIES COMPILE_FLAGS "-DWIN")
endif()

add_executable(calculator_app main.cpp)
target_link_libraries(calculator_app dl calculator)
